#include "Q7_1.h"

bool Isvalid(Date date)
{
	bool flag = true;
	if(date.dow < 0 || date.dow > 6)
		flag = false;
	if(date.month <= 0 ||date.month >12)
		flag = false;
	if(date.year <= 0)
		flag = false;
	switch(date.month)
	{
	case 1: case 3: case 5: case 7: case 8: case 10: case 12:
		if(date.day <= 0 || date.day > 31)
			flag = false;
		break;
	case 4: case 6: case 9: case 11:
		if(date.day <= 0 || date.day > 30)
			flag = false;
		break;
	case 2:
		if(date.year%400 == 0 || (date.year%4 == 0 && date.year%100 != 0))
		{
			if(date.day <= 0 ||date. day > 29)
				flag = false;
		}else
		{
			if(date.day <= 0 || date.day > 28)
				flag = false;
		}
		break;
	};
	return flag;
}

void q7_3_run()
{
	printf("Q7_3\n");
	Date *date = new Date(0, 1, 1, 2014);

	if(Isvalid(*date))
		ShowDate(*date);
	else
		printf("Mistack!\n");
}